#encoding=utf-8

import unittest
import time
from common.element import SetElements
from common.driver import Appium_Driver
import os

class Jisuan(unittest.TestCase):

    def setUp(self):
        self.driver=Appium_Driver().getDriver()



    def tearDown(self):
        self.driver.quit()

    def testMouth(self):
        e = SetElements()
        time.sleep(2)
        e.get_name('发现',self.driver).click()
        e.get_name('小程序',self.driver).click()
        e.get_name('工资个税计算器2019',self.driver).click()
        print("进入小程序内")
        time.sleep(3)
        # 不需要切换
        # driver.switch_to('WEBVIEW_com.tencent.mm:tools')

        e.get_xpath("//*[@class='android.view.View' and @instance='3']",self.driver).click()  #月薪
        e.fast_input(100000)
        # e.get_xpath("//*[@class='android.view.View' and @instance='3']", self.driver).set_text(100000)
        try:
            time.sleep(1)
            text = e.get_xpath("//*[@class='android.view.View' and @instance=3]", self.driver).get_text()
            print(text)
            self.assertEqual(text, '100000', msg="")
            print("输入月薪ok")
        except:
            print("输入月薪fail")



        e.get_xpath("//*[@class='android.view.View' and @instance='8']", self.driver).click()   #年终奖
        e.fast_input(100000)
        try:
            time.sleep(2)
            text = e.get_xpath("//*[@class='android.view.View' and @instance=8]", self.driver).get_attribute('text')
            print(text)
            self.assertEqual(text, '100000', msg="")
            print("输入年终奖ok")
        except:
            print("输入年终奖fail")



        e.get_xpath("//*[@class='android.view.View' and @instance='14']",self.driver).click()     #选择房贷
        print('选择房贷ok')

        e.get_xpath("//*[@class='android.view.View' and @instance=17]", self.driver).click()       #点击子女教育
        time.sleep(1)
        e.get_xpath("//*[@class='android.view.View' and @instance=37]", self.driver).click()      # 加
        e.get_xpath("//*[@class='android.view.View' and @instance=39]", self.driver).click()  # 点击确定，关闭弹框
        try:
            text = e.get_xpath("//*[@class='android.view.View' and @instance=18]", self.driver).get_attribute('text')
            self.assertIsNot(text, '1000元/月', msg="")
            print("子女教育ok")
        except:
            print("子女教育fail")


        e.get_xpath("//*[@class='android.view.View' and  @instance=20]", self.driver).click()  #赡养老人
        time.sleep(1)
        e.get_xpath("//*[@class='android.view.View' and  @instance=37]", self.driver).clear()
        e.fast_input(2000)
        e.get_xpath("//*[@class='android.view.View' and  @instance=40]", self.driver).click()   #点击确定，关闭弹框
        try:
            text = e.get_xpath("//*[@class='android.view.View' and @instance=21]", self.driver).get_attribute('text')
            self.assertEqual(text,'2000元/月',msg='')
            print("赡养老人ok")
        except:
            print('赡养老人fail')


        e.get_xpath("//*[@class='android.view.View' and @instance=26]", self.driver).click()   #大病医疗
        e.get_xpath("//*[@class='android.view.View' and @instance=37]", self.driver).clear() #输入金额：45000
        e.fast_input(45000)
        e.get_xpath("//*[@class='android.view.View' and @instance=40]", self.driver).click()  #点击确定，关闭弹框
        try:
            text = e.get_xpath("//*[@class='android.view.View' and @instance=27]", self.driver).get_attribute('text')
            self.assertEqual(text,'2500元/月',msg='')
            print('大病医疗ok')
        except:
            print('大病医疗fail')



        e.get_xpath("//*[@class='android.view.View' and @instance=29]", self.driver).click()  #继续教育，默认学历继续教育
        # e.get_xpath("//*[@class='android.view.View' and @instance=37]", self.driver).click()   #技能人员
        e.get_xpath("//*[@class='android.view.View' and @instance=39]", self.driver).click()  # 点击确定，关闭弹框
        try:
            text = e.get_xpath("//*[@class='android.view.View' and @instance=30]", self.driver).get_attribute('text')
            self.assertEqual(text,'400元/月',msg='')
            print('继续教育ok')
        except:
            print('继续教育fail')


        e.get_xpath("//*[@instance=31]", self.driver).click()  # 点击计算
        #进入结果页，进行数据校验






























































